<template lang="">
  <div>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <ul class="list">
        <li
          class="item"
          v-for="item in list"
          :key="item.id"
          @click="itemClick(item)"
        >
          <img :src="item.scene_pic_url" alt="" />
          <h2>{{ item.title }}</h2>
          <p class="subtitle">{{ item.subtitle }}</p>
          <p class="price">{{ item.price_info }}元起</p>
        </li>
      </ul>
    </van-list>
  </div>
</template>
<script>
import { listaction } from "@/api/topic/index";
export default {
  data() {
    return {
      list: [],
      loading: false,
      finished: false,
      page: 1,
    };
  },
  methods: {
    onLoad() {
      // 异步更新数据
      // setTimeout 仅做示例，真实场景中一般为 ajax 请求
      this.getList();
    },
    getList() {
      listaction({
        page: this.page,
      }).then((res) => {
        this.list.push(...res.data.data);
        this.loading = false;
        this.page++;
        if (this.page > res.data.total) {
          this.finished = true;
        }
      });
    },
    itemClick(item) {
      
      this.$router.push({
        path: "/topic/topicdetail",
        query: {
          id: item.id,
        },
      });
    },
  },
};
</script>
<style lang="scss">
@import "./index.scss";
</style>
